package com.mobclick.android;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.util.Log;

public class k
{
  private LocationManager a;
  private Context b;

  public k(Context paramContext)
  {
    this.b = paramContext;
  }

  public Location a()
  {
    Location localLocation;
    try
    {
      this.a = ((LocationManager)this.b.getSystemService("location"));
      if (j.a(this.b, "android.permission.ACCESS_FINE_LOCATION"))
      {
        localLocation = this.a.getLastKnownLocation("gps");
        if (localLocation != null)
        {
          if (!(UmengConstants.testMode))
            break label213;
          Log.i("MobclickAgent", "get location from gps:" + localLocation.getLatitude() + "," + localLocation.getLongitude());
        }
      }
      else if (j.a(this.b, "android.permission.ACCESS_COARSE_LOCATION"))
      {
        localLocation = this.a.getLastKnownLocation("network");
        if (localLocation != null)
        {
          if (!(UmengConstants.testMode))
            break label213;
          Log.i("MobclickAgent", "get location from network:" + localLocation.getLatitude() + "," + localLocation.getLongitude());
        }
      }
    }
    catch (Exception localException)
    {
      if (UmengConstants.testMode)
        Log.e("MobclickAgent", "getLocation error" + localException.getMessage());
      localLocation = null;
      break label213:
      if (UmengConstants.testMode)
        Log.i("MobclickAgent", "Could not get location from GPS or Cell-id, lack ACCESS_COARSE_LOCATION or ACCESS_COARSE_LOCATION permission?");
      localLocation = null;
    }
    label213: return localLocation;
  }
}